<?php
App::uses('AppController', 'Controller');
  
/**
 * Consignments Controller
 *
 * @property Consignment $Consignment
 */
 
class ConsignmentItemController  extends AppController {

	public function viewitem($id) {	
		
		
		
		$id = $this->request->params['pass'][0];
		if ($this->request->is ( "ajax" )) {
			$this->layout = null;
		}
		$this->set ( "id", $id );
		
	   $msg = array (
			__ ( 'The Item has been saved' ),
			__ ( 'The Item could not be saved. Please, try again.' )
		);
		header ( "Pragma: no-cache" );
		header ( "Cache-Control: no-store, no-cache, max-age=0, must-revalidate" );
		header ( 'Content-Type: text/x-json' );
		header ( 'Content-type: application/json' );
		$consignmentItem = array ();
		$itemlist = array ();
		$status=false;

		$options = array (
					"conditions" => array (
							"ConsignmentItem.consignment_id" => $id
					) 
			);
			
		$consignmentItem = $this->ConsignmentItem->find ( "all",$options );
				
		
		foreach ( $consignmentItem as $v ) {$itemlist[]=$v["Item"];}					
		foreach ( $itemlist as $name ) {$namearray[]=$name["name"];}	
		
		
//		http://localhost/CakePHP/items/view/1
		print_r($itemlist);
		echo $name = implode(',',$namearray);
		$this->redirect ( "/Consignments" );
	
		die ();
		
		

	//	$this->set ( "consignmentItem", $consignmentItem );
		
		}
	
	}

?>
<a href='http://localhost/CakePHP/items/view/$v["Item"][$key]['id']'>$v["Item"][$key]['name']</a>
